package my.avoskagae.service.rpc.server;

import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import my.avoskagae.model.AvoskaModelException;
import my.avoskagae.model.buslogic.MaintenanceProductCatalog;
import my.avoskagae.model.entity.Product;
import my.avoskagae.service.rpc.client.AvoskaServiceRPC;

@Singleton
public class AvoskaServiceRPCImpl extends RemoteServiceServlet implements AvoskaServiceRPC {

	private static final long serialVersionUID = 1L;

	@Inject
	protected MaintenanceProductCatalog maintenanceProductCatalog;
	
	public AvoskaServiceRPCImpl() {
	}
	
	@Override
	public Product createProduct(String name) throws AvoskaModelException {
		return maintenanceProductCatalog.createProduct(name);
	}

	@Override
	public List<Product> getProducts() throws AvoskaModelException {
		return maintenanceProductCatalog.getProducts();
	}

	@Override
	public boolean removeProduct(Product product) throws AvoskaModelException{
		return maintenanceProductCatalog.removeProduct(product);
	}

	@Override
	public Product renameProduct(Product product, String newName) throws AvoskaModelException{
		return maintenanceProductCatalog.renameProduct(product, newName);
	}

	@Override
	public Product switchNeedPurchase(Product product, Boolean newNeedPurchase) {
		return maintenanceProductCatalog.switchNeedPurchase(product, newNeedPurchase);
	}

}
